//
//  UILabel+Utils.h
//  WXReader
//
//  Created by LL on 2021/9/10.
//  Copyright © 2021 Andrew. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UILabel (Utils)

/// 计算文字1行显示所需要的宽度
@property (nonatomic, readonly) CGFloat w_textWidth;

/**
 * 计算文字显示所需要的高度
 *
 * 需要提前设置 preferredMaxLayoutWidth 属性
 */
@property (nonatomic, readonly) CGFloat w_textHeight;

- (void)attributedStringWithHTMLText:(NSString *)text
                                            fontSize:(CGFloat)fontSize
                                    characterSpacing:(CGFloat)characterSpacing
                                        lineSpacing:(CGFloat)lineSpacing
                                    paragraphSpacing:(CGFloat)paragraphSpacing
                                           alignment:(NSTextAlignment)alignment;
- (void)attributedStringWithHTMLText:(NSString *)text
                            fontSize:(CGFloat)fontSize
                    characterSpacing:(CGFloat)characterSpacing
                        lineSpacing:(CGFloat)lineSpacing
                   paragraphSpacing:(CGFloat)paragraphSpacing
                          alignment:(NSTextAlignment)alignment
                ifExceedWidthThen:(void (^)(CGFloat requiredHeight))exceedBlock;
@end

NS_ASSUME_NONNULL_END
